// DlgUpdate.cpp: Implementierungsdatei
//

#include "stdafx.h"
#include "Charplan.h"
#include "DlgUpdate.h"


// CDlgUpdate-Dialogfeld

IMPLEMENT_DYNAMIC(CDlgUpdate, CDialog)

CDlgUpdate::CDlgUpdate(CWnd* pParent /*=NULL*/)
        : CDialog(CDlgUpdate::IDD, pParent)
{
    mdw_version = 0;
}

CDlgUpdate::~CDlgUpdate()
{
}

void CDlgUpdate::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_VERSION_TEXT, mwnd_version_text);
}


BEGIN_MESSAGE_MAP(CDlgUpdate, CDialog)
    ON_BN_CLICKED(IDC_BUTTON2, &CDlgUpdate::OnBnClickedButton2)
    ON_BN_CLICKED(IDC_BUTTON4, &CDlgUpdate::OnBnClickedButton4)
    ON_BN_CLICKED(IDC_BUTTON1, &CDlgUpdate::OnBnClickedButton1)
    ON_BN_CLICKED(IDC_BUTTON3, &CDlgUpdate::OnBnClickedButton3)
END_MESSAGE_MAP()


// CDlgUpdate-Meldungshandler

void CDlgUpdate::OnBnClickedButton2()
{
    EndDialog(1);
}

void CDlgUpdate::OnBnClickedButton4()
{
    EndDialog(2);
}

void CDlgUpdate::OnBnClickedButton1()
{
    EndDialog(3);
}

void CDlgUpdate::OnBnClickedButton3()
{
    EndDialog(0);
}


BOOL CDlgUpdate::PreTranslateMessage(MSG* pMsg)
{
    mToolTips.RelayEvent(pMsg);
    return CDialog::PreTranslateMessage(pMsg);
}


INT_PTR CDlgUpdate::DoModal(DWORD dw_version)
{
    mdw_version = dw_version;

    return CDialog::DoModal();
}


BOOL CDlgUpdate::OnInitDialog()
{
    CDialog::OnInitDialog();

    mToolTips.Create(this);
    mToolTips.SetDelayTime(TTDT_AUTOPOP,0);
    mToolTips.SetDirection(PPTOOLTIP_TOPEDGE_LEFT);
    mToolTips.SetBehaviour(PPTOOLTIP_CLOSE_LEAVEWND);
    mToolTips.SetDelayTime(TTDT_INITIAL,500);

    mToolTips.AddTool(GetDlgItem(IDC_BUTTON3),IDS_UPDATE_LATER);
    mToolTips.AddTool(GetDlgItem(IDC_BUTTON2),IDS_UPDATE_BACKGROUND);
    mToolTips.AddTool(GetDlgItem(IDC_BUTTON4),IDS_UPDATE_MANUAL);
    mToolTips.AddTool(GetDlgItem(IDC_BUTTON1),IDS_UPDATE_HOMEPAGE);

    if (mdw_version==0)
    {
        mwnd_version_text.SetWindowText(_T(""));
    }
    else
    {
        CString temp;
        if ((mdw_version&0xff) != 0)
            temp.Format(_T("Charplan v%i.%i.%i.%i"),(mdw_version>>24)&0xff,(mdw_version>>16)&0xff,(mdw_version>>8)&0xff,(mdw_version&0xff));
        else
            if (((mdw_version>>8)&0xff) != 0)
                temp.Format(_T("Charplan v%i.%i.%i"),(mdw_version>>24)&0xff,(mdw_version>>16)&0xff,(mdw_version>>8)&0xff);
            else
                temp.Format(_T("Charplan v%i.%i"),(mdw_version>>24)&0xff,(mdw_version>>16)&0xff);

        mwnd_version_text.SetWindowText(temp);
    }

    return TRUE;
}
